﻿// LightNet - Lightweight .NET Framework
// Copyright (c) 2010 http://lightnet.codeplex.com

namespace System
{
    using System.Runtime.CompilerServices;
    using System.Runtime.ConstrainedExecution;
    using System.Runtime.InteropServices;
    using System.Security;

    /// <summary>
    /// Supports all classes in the .NET Framework class hierarchy and provides low-level services to derived classes.
    /// This is the ultimate base class of all classes in the .NET Framework; it is the root of the type hierarchy.
    /// </summary>
    [ClassInterface(ClassInterfaceType.AutoDual), ComVisible(true)]
    public class Object
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="T:System.Object" /> class.
        /// </summary>
        [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
        public Object()
        {
        }

        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object" /> is equal to the current <see cref="T:System.Object" />.
        /// </summary>
        /// <param name="obj">The <see cref="T:System.Object" /> to compare with the current <see cref="T:System.Object" />.</param>
        /// <returns>true if the specified <see cref="T:System.Object" /> is equal to the current <see cref="T:System.Object" />; otherwise, false.</returns>
        public virtual bool Equals(object obj)
        {
            return RuntimeHelpers.Equals(this, obj);
        }

        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object" /> instances are considered equal.
        /// </summary>
        /// <param name="objA">The first <see cref="T:System.Object" /> to compare.</param>
        /// <param name="objB">The second <see cref="T:System.Object" /> to compare.</param>
        /// <returns>true if <paramref name="objA" /> is the same instance as <paramref name="objB" /> or if both are null references or if objA.Equals(objB) returns true; otherwise, false.</returns>
        /// <exception cref="T:System.NullReferenceException">The <paramref name="obj" /> parameter is null.</exception>
        public static bool Equals(object objA, object objB)
        {
            return ((objA == objB) || (((objA != null) && (objB != null)) && objA.Equals(objB)));
        }

        /// <summary>
        /// Serves as a hash function for a particular type.
        /// </summary>
        /// <returns>A hash code for the current <see cref="T:System.Object" />.</returns>
        public virtual int GetHashCode()
        {
            return RuntimeHelpers.GetHashCode(this);
        }

        /// <summary>
        /// Gets the <see cref="T:System.Type" /> of the current instance.
        /// </summary>
        /// <returns>The <see cref="T:System.Type" /> instance that represents the exact runtime type of the current instance.</returns>
        [MethodImpl(MethodImplOptions.InternalCall), SecuritySafeCritical]
        public extern Type GetType();

        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object" /> instances are the same instance.
        /// </summary>
        /// <param name="objA">The first <see cref="T:System.Object" /> to compare.</param>
        /// <param name="objB">The second <see cref="T:System.Object" /> to compare.</param>
        /// <returns></returns>
        [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
        public static bool ReferenceEquals(object objA, object objB)
        {
            return (objA == objB);
        }

        /// <summary>
        /// Returns a <see cref="T:System.String" /> that represents the current <see cref="T:System.Object" />.
        /// </summary>
        /// <returns>A <see cref="T:System.String" /> that represents the current <see cref="T:System.Object" />.</returns>
        public virtual string ToString()
        {
            throw new NotImplementedException();
        }

        [MethodImpl(MethodImplOptions.InternalCall), SecuritySafeCritical]
        protected extern object MemberwiseClone();

        [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
        protected virtual void Finalize()
        {
        }
    }
}
